import * as types from './mutation-types'
import Vue from 'vue'
// ADD by liangqi
import store from 'src/store'

export default {
  [types.REFRESH_CUST_RIGHT] (state, data) { // 点击卡片刷新右侧
    Vue.set(state.transCache, 'refreshCustRight', data)
  },
  [types.CAll_SCREEN] (state, data) { // 开启来电来电弹屏自动跳转到去电
    Vue.set(state.transCache, 'callScreen', data)
  },
  [types.TEMP_CUSTOMER_DATA] (state, data) { // 去电通话中 =》 新增客户或者是合并客户的操作要把数据临时存储
    Vue.set(state.transCache, 'tempCustomerData', data)
  },
  [types.SET_CUSTOMER_INFO] (state, {data, callSheetId}) { // 更新来电的客户信息
    Vue.set(state.current.cdr_call.currentSession, callSheetId, data)
  },
  [types.QUERY_CALL_LIST] (state, {data, type}) { // 存储查询到的通话列表：来电，待处理，全部
    Vue.set(state.callList, type, data)
  },
  [types.SET_CALL_INFO] (state, {data, type}) { // 设置当前通话的通话信息
    Vue.set(state.current[type], 'callInfo', data)
  },
  [types.SET_CALL_INFO_CUSTOMER_ID] (state, {data, type}) { // 更新callInfo里面的customerId(通话中的时候，没有生成通话，得手动维护客户信息)
    Vue.set(state.current[type].callInfo, 'CUSTOMER_ID', data)
  },
  [types.QUERY_IVR_CONTRAIL] (state, {data, type}) { // ivr轨迹
    Vue.set(state.current[type].callInfo, 'ivr_contrail', data)
  },
  [types.QUERY_CALL_HISTORY] (state, {data, type}) { // 存储重复来电的通话历史
    let history = state.current[type].callInfo.call_history
    let list = []
    if (history) {
      list = history.list || []
    }
    data.list = list.concat(data.list)
    Vue.set(state.current[type].callInfo, 'call_history', data)
  },
  [types.QUERY_TRANSFER_CONTRAIL] (state, {transferRecords, type}) { // 转接轨迹的数据 array
    Vue.set(state.current[type].callInfo, 'transfer_contrail', transferRecords)
  },
  [types.QUERY_CALL_LABEL_TYPE] (state, data) {  // 获取通话标签类型 eg: 单标签or多级标签
    Vue.set(state.transCache, 'callLabelType', data)
  },
  [types.SAVE_CDR_MEMO] (state, {memo, type}) { // 当前卡片上编辑的记录和右侧已点开的记录是同一个通话记录，要做实时同步
    if (state.current[type].callInfo) {
      Vue.set(state.current[type].callInfo, 'COMMENTS', memo)
    }
  },
  [types.RELOCATION_CUSTOMER] (state, {relocationCustomerType, type}) { // 经搜索没用上，待验证
    Vue.set(state.current[type].callInfo, 'relocationCustomerType', relocationCustomerType)
  },
  [types.SET_CALL_NUM] (state, options) { // 其他模块点击短信带过来的号码
    Vue.set(state.transCache, 'megNum', options.phoneNum)
  },
  [types.SET_CALL_MULTI_LABEL] (state, data) { // 临时存储多级标签
    Vue.set(state.transCache, 'multiLabel', data)
  },
  [types.SET_CALL_SINGLE_LABEL] (state, data) { // 临时存储单标签
    Vue.set(state.transCache, 'singleLabel', data)
  },
  [types.SET_SHOW_KEY_TAG] (state, data) { // 每次把要去除通话标记的通话id存储起来，用于同时消除卡片中的icon
    let arr = state.transCache.showKeyTagArr || []
    arr.push(data)
    Vue.set(state.transCache, 'showKeyTagArr', arr)
  },
  [types.PUSH_CDR_OUTBOUND] (state, data) {
    let list = state.callList.cdr_outbound.list || []
    if (list.length >= 20) {
      var deleteDataList = list.splice(19)
      deleteDataList.forEach(deleteData => {
        if (deleteData._id === store.state.curCallSheetId) {   //   如果当前来电id不在 20个来电列表内，隐藏来电弹屏
          let page = document.getElementById('call_out_interface_wrap')
          if (page) {
            page.style.display = 'none'
          }
        }
      })
    }
    list.unshift(data)
    Vue.set(state.callList.cdr_outbound, 'list', list)
    Vue.set(state.callList.cdr_outbound, 'count', list.length)
    window.sessionStorage.setItem('callOutList', JSON.stringify(list))
  },
  [types.UPDATE_REPEAT_CALL] (state, data) { // 更新是否是重复来电
    let list = state.callList.cdr_call.list || []
    list.forEach(item => {
      if (item.CALL_SHEET_ID === data.callSheetId) {
        item.REPEAT_CALL = data.repeat
      }
    })
    Vue.set(state.callList.cdr_call, 'list', list)
    window.sessionStorage.setItem('callList', JSON.stringify(list))
  },
  [types.PUSH_CDR_CALL] (state, data) { // 每次来电时往通话来电列表添加数据
    let list = state.callList.cdr_call.list || []
    let item = {}
    item._id = data.callSheetId
    item.CALL_SHEET_ID = data.callSheetId
    item.CALL_NO = data.originCallNo
    item.QUICK_QUERY_NUM = data.originCallNo
    item.CALLED_NO = data.originCalledNo
    item.OFFERING_TIME = data.offeringTime
    item.PROVINCE = data.callerProvince
    item.DISTRICT = data.callerCity
    item.ivrkey = data.ivrkey
    if (data.TANPING) {
      item.TANPING = data.TANPING
    }
    if (data.CUSTOMVAR) {
      item.CUSTOMVAR = data.CUSTOMVAR
    }
    item.Agent = data.Agent
    item.RingTime = data.RingTime
    item.ERROR_MEMO = data.queue
    item.STATUS = data.CallStatus
    item.QUEUE_NAME = data.queueName
    item.unRead = data.unRead
    item.REPEAT_CALL = data.REPEAT_CALL
    item.CONNECT_TYPE = data.CONNECT_TYPE
    item.status = data.status
    if (data.CUSTOMER_STATUS) {
      item.CUSTOMER_STATUS = data.CUSTOMER_STATUS
    }
    if (data.CUSTOMER_NAME) {
      item.CUSTOMER_NAME = data.CUSTOMER_NAME
    }
    if (data.CUSTOMER_ID) {
      item.CUSTOMER_ID = data.CUSTOMER_ID
    }
    if (data.CUSTOMER_TYPE) {
      item.CUSTOMER_TYPE = data.CUSTOMER_TYPE
    }
    if (data.CUSTOMER_MEMO) {
      item.CUSTOMER_MEMO = data.CUSTOMER_MEMO
    }
    if (data.transferFrom) {
      item.transferFrom = data.transferFrom
    }
    if (data.transferTo) {
      item.transferTo = data.transferTo
    }
    if (data.waitTimeOut) {
      item.waitTimeOut = data.waitTimeOut
    }
    if (data.transferFromWhenWaitTimeout) {
      item.transferFromWhenWaitTimeoutNum = data.transferFromWhenWaitTimeoutNum
    }
    if (data.transferToWhenWaitTimeout) {
      item.transferToWhenWaitTimeoutNum = data.transferToWhenWaitTimeoutNum
    }
    // ADD by liangqi
    if (list.length >= 20) {
      console.log(store.state.curCallSheetId)  //   来电当前通话id
      var deleteDataList = list.splice(19)
      deleteDataList.forEach(deleteData => {
        if (deleteData._id === store.state.curCallSheetId) {   //   如果当前来电id不在 20个来电列表内，隐藏来电弹屏
          let page = document.getElementById('call_interface_wrap')
          if (page) {
            page.style.display = 'none'
          }
        }
        store.commit('REMOVE_ROUTE', {
          type: 'call',
          id: deleteData._id
        })
      })
    }
    // ADD end
    list.unshift(item)
    Vue.set(state.callList.cdr_call, 'list', list)
    Vue.set(state.callList.cdr_call, 'count', list.length)
  },
  [types.DELETE_CURRENT_CDR_CALL] (state, data) { // 来电快捷关闭会话之后把当前的list根据id剔除
    let list = state.callList[data.tabType].list || []
    for (let i = 0; i < list.length; i++) {
      if (list[i]._id === data._id) {
        list.splice(i, 1)
        break
      }
    }
    Vue.set(state.callList[data.tabType], 'list', list)
    Vue.set(state.callList[data.tabType], 'count', list.length)
    let storage = window.sessionStorage
    if (data.tabType === 'cdr_call') {
      if (storage.getItem('callList')) { // 把缓存里面的相对应通话也删除
        if (list) {
          storage.setItem('callList', JSON.stringify(list))
        }
      }
    } else if (data.tabType === 'cdr_outbound') {
      if (state.callList.cdr_outbound.list) {
        window.sessionStorage.setItem('callOutList', JSON.stringify(state.callList.cdr_outbound.list))
      }
    }
  },
  //记录当前使用的话术导航到对应的list
  [types.SAVE_CURRENT_SPEACH] (state, data) {
    let list = state.callList[data.tabType].list || []
    for (let i = 0; i < list.length; i++) {
      if (list[i]._id === data._id) {
        list[i].saveIntelligentSpeach = data.data
      }
    }
    Vue.set(state.callList[data.tabType], 'list', list)
    Vue.set(state.callList[data.tabType], 'count', list.length)
    if(data.tabType == 'cdr_call'){
      if(state.callList.cdr_call.list){
        window.sessionStorage.setItem('callList', JSON.stringify(state.callList.cdr_call.list))
      }
    }else if(data.tabType == 'cdr_outbound'){
      if (state.callList.cdr_outbound.list) {
        window.sessionStorage.setItem('callOutList', JSON.stringify(state.callList.cdr_outbound.list))
      }
    }
  },
  [types.PUSH_CURRENT_CDR_CALL] (state, data) {
    // 当前通话的客户信息
    let item = {}
    item._id = data.callSheetId
    item.CALL_SHEET_ID = data.callSheetId
    item.CALL_NO = data.originCallNo
    item.QUICK_QUERY_NUM = data.originCallNo
    item.CALLED_NO = data.originCalledNo
    item.OFFERING_TIME = data.offeringTime
    item.PROVINCE = data.callerProvince
    item.DISTRICT = data.callerCity
    if (data.ivrkey) {
      item.ivrkey = data.ivrkey
    }
    item.TANPING = data.TANPING
    item.CUSTOMVAR = data.CUSTOMVAR
    item.Agent = data.Agent
    item.RingTime = data.RingTime
    item.ERROR_MEMO = data.queue
    item.STATUS = data.CallStatus
    item.QUEUE_NAME = data.queueName
    item.REPEAT_CALL = data.REPEAT_CALL
    if (data.CUSTOMER_STATUS) {
      item.CUSTOMER_STATUS = data.CUSTOMER_STATUS
    }
    if (data.CUSTOMER_NAME) {
      item.CUSTOMER_NAME = data.CUSTOMER_NAME
    }
    if (data.CUSTOMER_ID) {
      item.CUSTOMER_ID = data.CUSTOMER_ID
    }
    if (data.CUSTOMER_TYPE) {
      item.CUSTOMER_TYPE = data.CUSTOMER_TYPE
    }
    if (data.CUSTOMER_MEMO) {
      item.CUSTOMER_MEMO = data.CUSTOMER_MEMO
    }
    if (data.transferFrom) {
      item.transferFrom = data.transferFrom
    }
    if (data.transferTo) {
      item.transferTo = data.transferTo
    }
    Vue.set(state.current.cdr_call, 'callInfo', item)
  },
  [types.UPDATE_CURRENT_CUSTOMER_INFO] (state, {callId, customer, onlyCard}) { // 更新当前的客户信息
    for (let callTab in state.callList) {
      state.callList[callTab].list && state.callList[callTab].list.forEach((callInfo, index) => {
        let info = state.callList[callTab].list[index]
        if (callInfo._id === callId && customer) {
          if (customer.name) {
            Vue.set(info, 'CUSTOMER_NAME', customer.name)
          }
          if (customer._id) {
            Vue.set(info, 'CUSTOMER_ID', customer._id)
          }
          if (customer.status) {
            Vue.set(info, 'CUSTOMER_STATUS', customer.status)
          }
          Vue.set(info, 'CUSTOMER_TYPE', 'one')
          if (!onlyCard) {
            Vue.set(state.current[callTab], 'currentCustomer', customer)
          }
        }
      })
      // 用于 来电后 更新客户信息后刷新
      if (callTab === 'cdr_call') {
        if (state.callList.cdr_call.list) {
          window.sessionStorage.setItem('callList', JSON.stringify(state.callList.cdr_call.list))
        }
      } else if (callTab === 'cdr_outbound') {
        if (state.callList.cdr_outbound.list) {
          window.sessionStorage.setItem('callOutList', JSON.stringify(state.callList.cdr_outbound.list))
        }
      }
    }
  },
  [types.UPDATE_CURRENT_CDRCALL_INFO] (state, {callSheetId, status}) {
    let list = state.callList.cdr_call.list
    if (list) {
      for (let i = 0; i < list.length; i++) {
        if (callSheetId === list[i]._id) {
          Vue.set(state.callList.cdr_call.list[i], 'status', status)
        }
      }
      console.log(list)
      let storage = window.sessionStorage
      if (storage.getItem('callList')) {
        if (list) {
          storage.setItem('callList', JSON.stringify(list))
        }
      }
    }
  },
  [types.SET_AUTO_CUST] (state, {callSheetId, autoCust}) { // 用于展示右侧详情中"定位到多个客户&选择一个客户"同个组件涉及其他模块的展示，此数据为标志值
    if (!state.autoCust) {
      Vue.set(state, 'autoCust', {})
    }
    Vue.set(state.autoCust, callSheetId, autoCust)
  },
  [types.SET_STORAGE_CALLLIST] (state, data) {  // 把来电list数据存储到sessionStorage，用于刷新系统后来电列表的重新展示
    if (state.callList.cdr_call.list) {
      window.sessionStorage.setItem('callList', JSON.stringify(state.callList.cdr_call.list))
    }
  },
  [types.SET_CALL_LIST_PUSH] (state, data) { // 设置来电的数据和count长度
    Vue.set(state.callList[data.tabType], 'list', data.list)
    Vue.set(state.callList[data.tabType], 'count', data.list.length)
  },
  [types.SET_READ] (state, callSheetId) { // 点击来电卡片之后，当前的卡片设置为已读
    let list = state.callList.cdr_call.list
    if (list) {
      for (let i = 0; i < list.length; i++) {
        if (callSheetId === list[i]._id) {
          Vue.set(state.callList.cdr_call.list[i], 'unRead', false)
        }
      }
      let storage = window.sessionStorage
      if (storage.getItem('callList')) { // 把缓存里面的相对应通话也改成已读
        if (list) {
          storage.setItem('callList', JSON.stringify(list))
        }
      }
    }
  },
  [types.SET_CDR_CALL_NEW_CALLID] (state, callObj) { // 外呼转接接起时,会生成一个新的id要重新存起来,用于来电里面的添加备注功能
    let list = state.callList.cdr_call.list
    if (list) {
      for (let i = 0; i < list.length; i++) {
        if (callObj.id === list[i]._id) {
          Vue.set(state.callList.cdr_call.list[i], 'dialoutNewCallId', callObj.newId)
        }
      }
      let storage = window.sessionStorage
      if (storage.getItem('callList')) { // 同时更新缓存里面的数据
        if (list) {
          storage.setItem('callList', JSON.stringify(list))
        }
      }
    }
  },
  [types.SET_CDR_CALL_NEW_STATUS] (state, callObj) { // 来电接起之后修改当前通话记录的通话状态
    let list = state.callList.cdr_call.list
    if (list) {
      for (let i = 0; i < list.length; i++) {
        if (callObj.id === list[i]._id) {
          Vue.set(state.callList.cdr_call.list[i], 'STATUS', callObj.status)
        }
      }
      let storage = window.sessionStorage
      if (storage.getItem('callList')) { // 同时更新缓存里面的数据
        if (list) {
          storage.setItem('callList', JSON.stringify(list))
        }
      }
    }
  },
  [types.UP_OR_HANDUP_FLAG] (state, upOrHandUpObj) { // 控制来电列表中编辑按钮的显示，电话进来时没有备注按钮，接起之后有备注按钮
    let list = state.callList.cdr_call.list
    if (list) {
      for (let i = 0; i < list.length; i++) {
        if (upOrHandUpObj.id === list[i]._id) {
          Vue.set(state.callList.cdr_call.list[i], 'upOrHandUpObj', upOrHandUpObj)
        }
      }
      let storage = window.sessionStorage
      if (storage.getItem('callList')) { //  同时更新缓存里面的数据
        if (list) {
          storage.setItem('callList', JSON.stringify(list))
        }
      }
    }
  },
  [types.COMMENTS] (state, data) { // 更新每个卡片中的备注和标签内容，用于备注和标签回显
    let list = state.callList[data.tabType].list
    if (list) {
      for (let i = 0; i < list.length; i++) {
        if (data.id === list[i]._id) {
          if (data.labels) {
            Vue.set(state.callList[data.tabType].list[i], 'LABELS', data.labels)
          } else {
            Vue.set(state.callList[data.tabType].list[i], 'COMMENTS', data.memo)
          }
        }
      }
      if (data.tabType === 'cdr_call') {
        let storage = window.sessionStorage
        if (storage.getItem('callList')) { //  同时更新缓存里面的数据
          if (list) {
            storage.setItem('callList', JSON.stringify(list))
          }
        }
      } else if (data.tabType === 'cdr_outbound') {
        window.sessionStorage.setItem('callOutList', JSON.stringify(state.callList[data.tabType].list))
      }
    }
  },
  [types.COUNT_UNREAD_CDR] (state) { // 计算未读来电数
    let result = 0
    let list = state.callList.cdr_call.list
    if (list && list.length > 0) {
      for (let i = 0; i < list.length; i++) {
        if (list[i].unRead) {
          result += 1
        }
      }
    }
    Vue.set(state, 'unReadCdr', result)
  },
  // 通话详情  提交录音 和  撤回录音 状态值改变
  [types.SET_QC_SUBMIT] (state, {tabType, QC_SUBMIT}) {
    Vue.set(state.current[tabType].callInfo, 'QC_SUBMIT', QC_SUBMIT)
  },
  [types.SET_CALL_MORE] (state, {activeName, more}) { // 用于获取是否有"查看更多"
    state.callList[activeName].more = more
  },
  [types.CALL_PENDING_NUMBERS] (state, count) {
    state.current.cdr_pending.pendingNumber = count
  },
  [types.CALL_SOUNDRECORDINGCARD_VISIBLE] (state, visible) {
    state.SoundrecordingCard.visible = visible
    if (!visible) {
      state.SoundrecordingCard.isPlay = true
    }
  },
  [types.CALL_SOUNDRECORDINGCARD_SOUNDURL] (state, url) {
    state.SoundrecordingCard.soundUrl = url
  },
  [types.CALL_SOUNDRECORDINGCARD_ISPLAY] (state, isPlay) {
    state.SoundrecordingCard.isPlay = isPlay
  },
  [types.CALL_SOUNDRECORDINGCARD_CURRENTTIME] (state, currentTime) {
    state.SoundrecordingCard.currentTime = currentTime
  },
  [types.SOCKET_TRANS] (state, data) {
    if (data.isMonitorNotice) {
      if (data.callAgent) {
        if (window.phone_peers[data.callAgent].sensitiveObj) {
          if (window.phone_peers[data.callAgent].sensitiveObj[data.callType]) {
            let agentArr = window.phone_peers[data.callAgent].sensitiveObj[data.callType].split(',')
            let newArr = data.callSensitiveText.split(',')
            for (var i = 0; i < newArr.length; i++) {
              if (agentArr.indexOf(newArr[i]) === -1) {
                agentArr.push(newArr[i])
              }
            }
            window.phone_peers[data.callAgent].sensitiveObj[data.callType] = agentArr.join(',')
          } else {
            window.phone_peers[data.callAgent].sensitiveObj[data.callType] = data.callSensitiveText
          }
        } else {
          window.phone_peers[data.callAgent].sensitiveObj = {}
          window.phone_peers[data.callAgent].sensitiveObj[data.callType] = data.callSensitiveText
        }
        let text = ''
        if (window.phone_peers[data.callAgent].sensitiveObj['agent']) {
          text += '座席：' + window.phone_peers[data.callAgent].sensitiveObj['agent'] + '</br>'
        }
        if (window.phone_peers[data.callAgent].sensitiveObj['customer']) {
          text += '客户：' + window.phone_peers[data.callAgent].sensitiveObj['customer']
        }
        window.phone_peers[data.callAgent].sensitive = text
        window.phone_peers[data.callAgent].sensitiveAgent = window.phone_peers[data.callAgent].sensitiveObj['agent']
        window.phone_peers[data.callAgent].sensitiveCustomer = window.phone_peers[data.callAgent].sensitiveObj['customer']
        store.commit('AGENT_STATE_CHANGE', data.callAgent)
      }
    } else {
      state.socketTransList.push(data)
      // if (!state.goldenMonitor[data.callSheetId]) { // 新会话
      //   Vue.set(state.goldenMonitor, data.callSheetId, {})
      // }
      // if (data.timeLen && data.wordLen) {
      //   const speed = Math.ceil((data.wordLen / 3) / (data.timeLen / 1000)) * 60 // 转写文字长度（3个字节一个汉字）除于 说话时长（毫秒）=> *60换算成 xx字/分钟
      //   Vue.set(state.goldenMonitor[data.callSheetId], 'speed', speed)
      // }
      // if (data.callType === 'customer' && data.end_time) { // 客户说话，用结束时间
      //   Vue.set(state.goldenMonitor[data.callSheetId], 'end_time', data.end_time)
      // }
      // if (data.callType === 'agent' && data.begin_time) { // 座席说话，用开始时间
      //   Vue.set(state.goldenMonitor[data.callSheetId], 'begin_time', data.begin_time)
      // }
      // if (state.goldenMonitor[data.callSheetId].begin_time > state.goldenMonitor[data.callSheetId].end_time) { // 抢话了，记录最近抢话时间,最近抢话语速
      //   Vue.set(state.goldenMonitor[data.callSheetId], 'prePreemptionTime', state.goldenMonitor[data.callSheetId].begin_time)
      //   Vue.set(state.goldenMonitor[data.callSheetId], 'preSpeed', state.goldenMonitor[data.callSheetId].speed)
      // }
      // window.sessionStorage.setItem('goldenMonitor', JSON.stringify(state.goldenMonitor)) // 存储本地一份，用于刷新系统后的取值
    }
  },
  // [types.GOLDEN_MONITOR] (state, data) {
  //   Vue.set(state, 'goldenMonitor', data)
  // },
  [types.SOCKET_OFFLINE_TRANS] (state, data) {
    state.socketOfflinetRransId = data.CallId
  },
  [types.CURRENT_TRANS_ID] (state, {callSheetId, type}) {
    state.transCallSheetId = callSheetId
    if (type) {
      state.currentType = type
    } else {
      state.socketTransList = []
    }
  },
  [types.SHOW_tRANS_BTN] (state, data) {
    state.callList[state.currentType].list.forEach((item, index) => {
      if (item.CALL_SHEET_ID === state.transCallSheetId) {
        Vue.set(state.callList[state.currentType].list[index], 'showTransBtn', true)
      }
    })
    if (state.currentType === 'cdr_call') {
      window.sessionStorage.setItem('callList', JSON.stringify(state.callList[state.currentType].list))
    } else if (state.currentType === 'cdr_outbound') {
      window.sessionStorage.setItem('callOutList', JSON.stringify(state.callList[state.currentType].list))
    }
  },
  [types.SET_PARTICIPLE_CON] (state, con) {
    state.participleCon = con
    // state.socketTrans = data
  },
  [types.CALL_TRANSEDIDS] (state, id) {
    state.transedIds.push(id)
    state.transedIds = Array.from(new Set(state.transedIds))
  },
  [types.CALL_DELETRANSEDIDS] (state, id) {
    let index = state.transedIds.indexOf(id)
    state.transedIds.splice(index, 1)
  },
  [types.INTELLIGENT_RECOMMEND](state,item){
    state.recommendList = []
    state.recommendList =state.recommendList.concat(item)
  },
  [types.INTELLIGENT_MATCH](state,item){
    if(Object.keys(item).length > 0){
      state.recommendMatch.push(item)
    }else{
      state.recommendMatch = []
    }
  },
  [types.SHOW_INTELLIGENT](state,item){
    state.showIntelligent = item
  },
  [types.TRANSFER_NO_INTELLIGENT](state,item){
    state.transferNoInteligent = item
  },
  [types.MATCH_DATA](state,data){
    let list = state.callList[data.tabType].list || []
    for (let i = 0; i < list.length; i++) {
      if (list[i]._id === data._id) {
        if(list[i].matchData){
          let exist = list[i].matchData.some(item=>{
            if(item.id == data.data[0].id){
              return true
            }
          })
          if(!exist){
            list[i].matchData = list[i].matchData.concat(data.data)
          }
        }else{
          list[i].matchData = data.data
        }
      }
    }
    Vue.set(state.callList[data.tabType], 'list', list)
    Vue.set(state.callList[data.tabType], 'count', list.length)
    if(data.tabType == 'cdr_call'){
      if(state.callList.cdr_call.list){
        window.sessionStorage.setItem('callList', JSON.stringify(state.callList.cdr_call.list))
      }
    }else if(data.tabType == 'cdr_outbound'){
      if (state.callList.cdr_outbound.list) {
        window.sessionStorage.setItem('callOutList', JSON.stringify(state.callList.cdr_outbound.list))
      }
    }
  }
}
